clear;

% Dataset sort by importance/size
% Dataset = 'Ddavid_CAL500_normal';
% Dataset = 'Ddavid_yeast';
% Dataset = 'Ddavid_emotions_normal';
% Dataset = 'Ddavid_scene';
% Dataset = 'Ddavid_mediamill_small';
% Dataset = 'Ddavid_birds';
% Dataset = 'Ddavid_EUR-Lex';
Dataset = 'Ddavid_NUS-WIDE-cVLADplus';

Incomplete_Label_Preprocessing_Option.TotalFoldNumber = 5;
% Incomplete_Label_Preprocessing_Option.UsedFoldNumber = 1;
Incomplete_Label_Preprocessing_Option.Name = Dataset;
% Incomplete_Label_Preprocessing_Option.SampledDataPercent = 80.0; % Incomplete labeled data
% Incomplete_Label_Preprocessing_Option.SampledLabelPercent = 25.0; % Max label number of imcomplete labeled data

PercentLabeledDataList = [20.0];
PercentKeepingLabelsList = [25.0];
FoldNumber = Incomplete_Label_Preprocessing_Option.TotalFoldNumber;

load(Incomplete_Label_Preprocessing_Option.Name);

% Percent of labeled data
for i = PercentLabeledDataList
    
    % Percent of keeping labels
    for j = PercentKeepingLabelsList
        Incomplete_Label_Preprocessing_Option.SampledDataPercent = i;
        Incomplete_Label_Preprocessing_Option.SampledLabelPercent = j;
        
        % Fold number
        for k = 1:FoldNumber
            Incomplete_Label_Preprocessing_Option.UsedFoldNumber = k;

            if(exist('AllDataTraining', 'var') && exist('TrueLabelTraining', 'var') && exist('AllDataTesting', 'var') && exist('TrueLabelTesting', 'var'))
                [AllData, TrueLabel, AllDataSampler, AllDataTraining, TrueLabelTraining, AllDataTesting, TrueLabelTesting, SampledTrueLabelTraining, SampledOnlyDataTraining, SampledOnlyTrueLabelTraining, UnsampledOnlyDataTraining, DataSampler, SampledDataSize, SampledLabelSize] = Ddavid_Incomplete_Label_Preprocessing(Incomplete_Label_Preprocessing_Option, AllDataTraining, TrueLabelTraining, AllDataTesting, TrueLabelTesting);
            else
                if(exist('AllData', 'var') && exist('TrueLabel', 'var'))
                    if(exist('AllDataSampler', 'var'))
                        [AllData, TrueLabel, AllDataSampler, AllDataTraining, TrueLabelTraining, AllDataTesting, TrueLabelTesting, SampledTrueLabelTraining, SampledOnlyDataTraining, SampledOnlyTrueLabelTraining, UnsampledOnlyDataTraining, DataSampler, SampledDataSize, SampledLabelSize] = Ddavid_Incomplete_Label_Preprocessing(Incomplete_Label_Preprocessing_Option, AllData, TrueLabel, AllDataSampler);
                    else
                        [AllData, TrueLabel, AllDataSampler, AllDataTraining, TrueLabelTraining, AllDataTesting, TrueLabelTesting, SampledTrueLabelTraining, SampledOnlyDataTraining, SampledOnlyTrueLabelTraining, UnsampledOnlyDataTraining, DataSampler, SampledDataSize, SampledLabelSize] = Ddavid_Incomplete_Label_Preprocessing(Incomplete_Label_Preprocessing_Option, AllData, TrueLabel);
                    end
                end
                clear AllDataTraining TrueLabelTraining AllDataTesting TrueLabelTesting;
            end
        end
        
        clear AllDataSampler;
    end
end

sound(sin(2 * pi * 25 * (1:1000) / 400));
